package com.li.youhappygo.controller;

import com.li.youhappygo.model.vo.common.Result;
import com.li.youhappygo.model.vo.common.ResultCode;
import com.li.youhappygo.service.FileUploadService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Tag(name = "文件上传", description = "文件上传")
public class FileUploadController {

    @Autowired
    FileUploadService fileUploadService;

    @PostMapping("uploadFile")
    @Operation(summary = "上传文件",description = "上传文件")
    public Result<String> uploadFile(@RequestParam("file") MultipartFile multipartFile){
        String url = fileUploadService.uploadFile(multipartFile);
        return Result.build(url, ResultCode.SUCCESS);
    }

}
